<ion-header>
    <ion-navbar core-back-button>
        <ion-title><core-format-text [text]="module.name" contextLevel="module" [contextInstanceId]="module.id" [courseId]="courseId"></core-format-text></ion-title>
        <ion-buttons end>
            <button ion-button (click)="save()"> {{ 'core.save' | translate }}</button>
        </ion-buttons>
    </ion-navbar>
</ion-header>
<ion-content>
    <core-loading [hideUntil]="loaded">
        <ion-list>
            <ion-item>
                <ion-label stacked>{{ 'addon.mod_glossary.concept' | translate }}</ion-label>
                <ion-input type="text" [placeholder]="'addon.mod_glossary.concept' | translate" [(ngModel)]="entry.concept"></ion-input>
            </ion-item>
            <ion-item>
                <ion-label stacked>{{ 'addon.mod_glossary.definition' | translate }}</ion-label>
                <core-rich-text-editor item-content [control]="definitionControl" (contentChanged)="onDefinitionChange($event)" [placeholder]="'addon.mod_glossary.definition' | translate" name="addon_mod_glossary_edit" [component]="component" [componentId]="glossary.cmid"></core-rich-text-editor>
            </ion-item>
            <ion-item *ngIf="categories.length > 0">
                <ion-label stacked id="addon-mod-glossary-categories-label">{{ 'addon.mod_glossary.categories' | translate }}</ion-label>
                <ion-select [(ngModel)]="options.categories" multiple="true" aria-labelledby="addon-mod-glossary-categories-label" interface="action-sheet" [placeholder]="'addon.mod_glossary.categories' | translate">
                    <ion-option *ngFor="let category of categories" [value]="category.id">{{ category.name }}</ion-option>
                </ion-select>
            </ion-item>
            <ion-item>
                <ion-label stacked id="addon-mod-glossary-aliases-label">{{ 'addon.mod_glossary.aliases' | translate }}</ion-label>
                <ion-textarea [(ngModel)]="options.aliases" rows="1" core-auto-rows aria-labelledby="addon-mod-glossary-aliases-label"></ion-textarea>
            </ion-item>
            <ion-item-divider>{{ 'addon.mod_glossary.attachment' | translate }}</ion-item-divider>
            <core-attachments [files]="attachments" [component]="component" [componentId]="glossary.cmid" [allowOffline]="true"></core-attachments>
            <ng-container *ngIf="glossary.usedynalink">
                <ion-item-divider>{{ 'addon.mod_glossary.linking' | translate }}</ion-item-divider>
                <ion-item text-wrap>
                    <ion-label>{{ 'addon.mod_glossary.entryusedynalink' | translate }}</ion-label>
                    <ion-toggle [(ngModel)]="options.usedynalink"></ion-toggle>
                </ion-item>
                <ion-item text-wrap>
                    <ion-label>{{ 'addon.mod_glossary.casesensitive' | translate }}</ion-label>
                    <ion-toggle [disabled]="!options.usedynalink" [(ngModel)]="options.casesensitive"></ion-toggle>
                </ion-item>
                <ion-item text-wrap>
                    <ion-label>{{ 'addon.mod_glossary.fullmatch' | translate }}</ion-label>
                    <ion-toggle [disabled]="!options.usedynalink" [(ngModel)]="options.fullmatch"></ion-toggle>
                </ion-item>
            </ng-container>
        </ion-list>
    </core-loading>
</ion-content>
